@extends('layouts.backend')
@section('title')
    分类列表
@endsection

@section('body')
    <div class="row">
        <div class="ibox">
            <div class="ibox-title">
                <h5>分类列表</h5>
            </div>
            <div class="ibox-content">
                <div class="row">

                    <div class="col-md-6">
                        <form role="form" class="form-inline" method="get">
                            <div class="form-group">
                                <input type="text" placeholder="Enter Keyword " value="{{request('keyword', '')}}" name="keyword" id="keyword" class="form-control">

                            </div>
                            <button class="btn btn-primary" type="submit">搜索</button>
                            <a href="{{ route('backend.category.index') }}" class="btn btn-warning">重置</a>
                            <a href="{{route('backend.category.create')}}" class="btn btn-primary m-md">添加分类</a>
                        </form>
                    </div>

                </div>
                <table class="table">
                    <thead>
                    <tr>
                        <th>#</th>
                        <th>名称</th>
                        <th>父类</th>
                        <th>文章数</th>
                        <th>创建时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    @forelse($categories as $category)
                        <tr>
                            <td>{{$category->id}}</td>
                            <td>{{$category->name}}</td>
                            <td>
                                {{$category->pid}}
                            </td>
                            <td>{{$category->post_count}}</td>
                            <td>{{$category->created_at}}</td>
                            <td>
                                <a href="{{route('backend.category.edit', $category)}}" class="btn btn-warning btn-sm">编辑</a>
                                @include('components.backend.destroy', ['url' => route('backend.category.destroy', $category)])
                            </td>
                        </tr>
                    @empty
                        <tr>
                            <td class="text-center" colspan="7">暂无记录</td>
                        </tr>
                    @endforelse
                    </tbody>
                </table>
            </div>
            <div class="ibox-footer">
                {{$categories->render()}}
            </div>
        </div>
    </div>
@endsection
